package hsintiao.com.XintiaoAppDoctor.controller;

import hsintiao.com.XintiaoAppDoctor.entity.User;
import hsintiao.com.XintiaoAppDoctor.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/hello")
public class HelloController {
    @Autowired
    private UserMapper userMapper;

    @GetMapping("/find")
    @ResponseBody
    public User findByID(Long id){
        try {
            User one = userMapper.findOne(id);
            return one;
        }catch (Exception e){
            e.printStackTrace();
            User user = new User();
            user.setName(e.getMessage());
            return user;
        }
    }
}
